//
//  NewestMiddleCollectionViewCell.m
//  livingDesign
//
//  Created by dlios on 15-1-29.
//  Copyright (c) 2015年 怡居. All rights reserved.
//

#import "NewestMiddleCollectionViewCell.h"

@implementation NewestMiddleCollectionViewCell
- (void)dealloc
{
    [_newestIV release];
    [_newestLabel release];
    [_newest release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.newestIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 40)];
        [self.contentView addSubview:self.newestIV];
//        self.newestIV.backgroundColor = [UIColor lightGrayColor];
        [self.newestIV release];
        
        self.newestLabel = [[UILabel alloc] initWithFrame:CGRectMake(3, self.frame.size.height - 40 + 5, self.frame.size.width - 10, 35)];
        [self.contentView addSubview:self.newestLabel];
        self.newestLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
//                self.newestLabel.backgroundColor = [UIColor redColor];
        self.newestLabel.font = [UIFont systemFontOfSize:14];
        [self.newestLabel release];
    }
    return self;
}


// 重写set方法
- (void)setNewest:(Newest *)newest
{
    _newest = newest;
//    NSLog(@"................ok");
//    NSLog(@"")
    [self showData];
}
- (void)showData
{
    NSString *strImage = self.newest.img;
    NSURL *url = [NSURL URLWithString:strImage];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *image = [UIImage imageWithData:data];
    self.newestIV.image = image;
    
    self.newestLabel.text = self.newest.title;
}


@end
